﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
using UnitFundProfitability.BusinessLogic;

namespace UnitFundProfitability
{
    /// <summary>
    /// Interaction logic for AddManagementCompany.xaml
    /// </summary>
    public partial class ManagementCompanies : Window
    {
        #region Constructos
        public ManagementCompanies()
        {
            InitializeComponent();
            AddCompany.Click += new RoutedEventHandler(AddCompany_Click);
            RefreshExistingCompanies();
        }
        #endregion

        #region Methods
        private void RefreshExistingCompanies()
        {
            List<ManagementCompany> dataContext = Manager.Instance.GetManagementCompanies();
            ExistingCompanies.DataContext = dataContext;
        }

        private void AddCompany_Click(object sender, RoutedEventArgs e)
        {
            ManagementCompany company = new ManagementCompany();
            company.CompanyId = Guid.NewGuid();
            company.CompanyName = CompanyName.Text;
            Manager.Instance.AddManagementCompany(company);
            RefreshExistingCompanies();
        }
        #endregion
    }
}